package jsyf.oa.web.report;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.LeaveReportFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(value = "请假报表接口", description = "请假报表接口")
@Controller
@RequestMapping("/reportLeave")

public class LeaveReportController {


    @Resource
    private LeaveReportFacade leaveReportFacade;

    @RequestMapping(value = "/getLeaveIsTodayList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "當日请假报表一级",
            notes = "请假报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getLeaveIsTodayList(HttpServletResponse response, @RequestBody String jsonData) {
        //JSONObject obj = JSON.parseObject(jsonData);
        List<JSONObject> result = this.leaveReportFacade.getLeaveIsTodayInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/getLeaveCompanyList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "请假报表一级",
            notes = "请假报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getLeaveCompanyList(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject obj = JSON.parseObject(jsonData);
        List<JSONObject> result = this.leaveReportFacade.getLeaveGroup(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/getLeavePersonList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "请假报表二级",
            notes = "请假报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getLeavePersonList(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject obj = JSON.parseObject(jsonData);
        List<JSONObject> result = this.leaveReportFacade.getLeavePersonList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/getLeaveInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "请假报表-卡片",
            notes = "请假报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getLeaveInfo(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject obj = JSON.parseObject(jsonData);
        JSONObject result = this.leaveReportFacade.getLeaveInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(result));
    }

}
